package perform.criterion;

public class Order {
	
	private StringBuilder builder;
	
	private Order(String column, boolean asc){
		builder = new StringBuilder("order by `").append(column);
		if(asc){
			builder.append("` acs");
		} else {
			builder.append("` decs");
		}
	}
	
	public static Order asc(String column){
		return new Order(column, true);
	}
	public static Order desc(String column){
		return new Order(column, false);
	}
	
	public Order add(String column, boolean asc){
		builder.append(" `").append(column);
		if(asc){
			builder.append("` asc");
		} else {
			builder.append("` desc");
		}
		return this;
	}
	
	@Override
	public final String toString() {
		return builder.toString();
	}

}
